var Redis = require('ioredis');
var red = new Redis(6379);
//测试githook
var game = {

	//游戏开始
	gameStart(socket){
		
	},

	update(key,field,value){
		red.hget(key,field,(e,r)=>{
			let data = {};
			if(field == "users"){
				data = JSON.parse(r);
			}else{
				data = r;
			}
			data = value;
			if(field == "users"){
				data = JSON.stringify(data);
			}
			rd.hset(key,field,data);
		});	
	},

	get(key,field){
		return new Promise((resolve,reject)=>{
			red.hget(key,field,(e,r)=>{
				if(field == "users"){
					r = JSON.parse(r);
				}
				resolve(r);
			});
		});
	}
}
module.exports = game;


//http://so.ytpp.com.cn/click/?w=https%3a%2f%2furl.cn%2f5eOmmLW
//https://m.so.com/tjump?u=https://www.mongodb.com/dr/fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-ssl-3.6.4-signed.msi/download